#include "cell/CellObject.h"
#include "world/Neighbor.h"

CellObject::CellObject() : state(DEAD)
{}

void CellObject::evolve(Neighbor& neighbor)
{
    CellState stateList[] = {DEAD, DEAD
            , neighbor.getSrcCell(pos).getState()
            , ALIVE, DEAD, DEAD, DEAD, DEAD, DEAD
    };
    state = stateList[neighbor.countNeighbors(pos)];
}

bool CellObject::isAlive() const
{
    return state.isAlive();
}

void CellObject::init(const Position& pos, CellState state)
{
    this->pos = pos;
    this->state = state;
}

bool CellObject::isEndl() const
{
    return pos.isEndl();
}

CellState CellObject::getState() const
{
    return state;
}
